$(function () {
var token = queryString("token");
console.log(token);
//document.getElementById('backbtn').href = "index.html?token="+token;
$("#backbtn").attr("href","index.html?token="+token);
getgift(1);

// 查询中奖记录
function getgift(page) {
    $.post("https://platform.shmixin.cn/usergame/query", {
        token: token,
        page: page
    }, (red) => {
        if (red.code == 1) {
            console.log('查询中奖记录成功');
            var html = "<tr><th>中奖时间 </th><th>中奖奖品</th><th>受理结果</th></tr>";
            
            if (red.data && red.data.length > 0) {
                red.data.forEach(item => {
                    html += "<tr><td>" + item.gametime + "</td><td>" + item.remarks + "</td><td>" + item.state + "</td>";
                });
            }
            $(".tb0").html(html);
        } else {
            console.log('查询中奖记录失败');
            $(this).blur();
            alert("查询中奖记录失败");
        }
    }
    );
}
//此处可以在commonjs中合并
function queryString(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.search);
    if (results === null) {
        return "";
    }
    else {
        return decodeURIComponent(results[1].replace(/\+/g, " "));
    }
}
})
